Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ [#4420] Validation for fields within AddressNL component #167

Merged
merged 6 commits into from
Aug 20, 2024

Conversation

stevenbal
Copy link
Contributor

@stevenbal stevenbal commented Jul 8, 2024

partially closes open-formulieren/open-forms#4420

Requires open-formulieren/types#51 to be merged and released first

@stevenbal stevenbal marked this pull request as draft July 8, 2024 10:48
@stevenbal stevenbal force-pushed the feature/4420-addressNL-fields-validation branch 7 times, most recently from a47cf07 to 5f1d2e7 Compare July 9, 2024 14:28
@stevenbal stevenbal force-pushed the feature/4420-addressNL-fields-validation branch 3 times, most recently from e7194c1 to 78c9ade Compare July 30, 2024 14:43
@stevenbal stevenbal force-pushed the feature/4420-addressNL-fields-validation branch 2 times, most recently from 76a1ac6 to d7bf6b2 Compare August 12, 2024 10:04
@stevenbal stevenbal marked this pull request as ready for review August 12, 2024 10:35
@stevenbal stevenbal force-pushed the feature/4420-addressNL-fields-validation branch from d7bf6b2 to bb41eb4 Compare August 12, 2024 14:27
src/registry/addressNL/edit.tsx Outdated Show resolved Hide resolved
src/registry/addressNL/edit.tsx Outdated Show resolved Hide resolved
@sergei-maertens sergei-maertens force-pushed the feature/4420-addressNL-fields-validation branch from bb41eb4 to b064b40 Compare August 15, 2024 07:51
@stevenbal stevenbal force-pushed the feature/4420-addressNL-fields-validation branch from d6feb8a to 01713f8 Compare August 19, 2024 11:52
@stevenbal stevenbal force-pushed the feature/4420-addressNL-fields-validation branch from 01713f8 to 91f9da5 Compare August 19, 2024 14:06
src/components/formio/datamap.tsx Outdated Show resolved Hide resolved
src/components/formio/datamap.tsx Outdated Show resolved Hide resolved
src/registry/addressNL/edit.stories.ts Outdated Show resolved Hide resolved
@stevenbal stevenbal force-pushed the feature/4420-addressNL-fields-validation branch from cee83da to 4027f66 Compare August 19, 2024 14:59
Comment on lines 93 to 95
const patternInput = canvas.getByLabelText(
'Regular expression for postcode'
) as HTMLInputElement;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the as casting should not be needed, often you can pass the expected type as a generic param: getByLabelText<HTMLInputElement> or if the problem is that it can be null or undefined, you can add an exclamation mark at the end saying that you know it will resolve:

canvas.getByLabelText("some label")!;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll pass the generic param, the exclamation mark doesn't work, it gives me the same error as when I don't add the type at all: Property 'value' does not exist on type 'HTMLElement'.ts(2339) (on the line expect(patternInput.value).toBe('Amsterdam');)

@stevenbal stevenbal force-pushed the feature/4420-addressNL-fields-validation branch 2 times, most recently from f3e73a6 to 65e171e Compare August 20, 2024 08:04
@sergei-maertens sergei-maertens force-pushed the feature/4420-addressNL-fields-validation branch from 65e171e to a431899 Compare August 20, 2024 10:03
stevenbal and others added 6 commits August 20, 2024 14:48
the following components can now be validated using regex:
* postcode
* city
* Use stricter types for the SubComponentValidation react component
  prop - not any string is accepted, it must be one of the two union
  members defined in the type
* pass the correct validation schema to 'useManageValidatorsTranslations',
  using the subcomponent schemas defined in the type
* use prefix for AddressNL SubcomponentValidation and useManageValidatorsTranslations
* remove unnecessary waitFor blocks in AddressNL stories
* add aria-label to datamap
by replacing getByLabelText with findByLabelText after userEvent.click(...)
@sergei-maertens sergei-maertens force-pushed the feature/4420-addressNL-fields-validation branch from 78af523 to d540808 Compare August 20, 2024 12:48
@sergei-maertens sergei-maertens merged commit 5d8adbb into main Aug 20, 2024
13 checks passed
@sergei-maertens sergei-maertens deleted the feature/4420-addressNL-fields-validation branch August 20, 2024 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validation for fields within AddressNL component
2 participants